//
//  JMAlbumController.m
//  PhotoLock
//
//  Created by 赵俊明 on 2017/7/15.
//  Copyright © 2017年 赵俊明. All rights reserved.
//

#import "JMAlbumController.h"
#import "JMAlbumModel.h"
#import "JMAddController.h"
#import "JMMainNavController.h"
#import "JMVideoDetailController.h"
#import "JMPhotoDetailController.h"

@interface JMAlbumController ()

@end

@implementation JMAlbumController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSArray *types = @[@"nil", @"Privatw Photos", @"Private Videos", @"My Videos"];
    NSArray *count = @[@"nil", @"20 Photos", @"10 Videos", @"20 Videos"];
    NSArray *imags = @[@"Add Album", @"play", @"play", @"play"];
    
    for (int i = 0; i < imags.count; i ++) {
        
        JMAlbumModel *model = [[JMAlbumModel alloc] init];
        model.albumType = types[i];
        model.albumCount = count[i];
        model.leftImage = imags[i];
        [self.dataSource addObject:model];
    }
    
    [self.collection reloadData];
    
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        
        JMNormalCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:collectionNormalID forIndexPath:indexPath];
        cell.model = self.dataSource[indexPath.row];
        return cell;
        
    }else{
    
        JMAlbumCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:collectionID forIndexPath:indexPath];
        cell.collection = collectionView;
        cell.model = self.dataSource[indexPath.row];
        return cell;
    }
}

#pragma mark UICollectionViewDelegate
// 选中某item
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        
        JMAddController *add = [[JMAddController alloc] init];
        JMMainNavController *navC = [[JMMainNavController alloc] initWithRootViewController:add];
        [self presentViewController:navC animated:YES completion:nil];
    
    }else if (indexPath.row == 1){
    
        JMPhotoDetailController *photos = [[JMPhotoDetailController alloc] init];
        [self.tabBarController.navigationController pushViewController:photos animated:YES];
        
    }else if (indexPath.row == 2){
        
        JMVideoDetailController *video = [[JMVideoDetailController alloc] init];
        [self.tabBarController.navigationController pushViewController:video animated:YES];
        
    }else if (indexPath.row == 3){
        
        
    }
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        
        return CGSizeMake(self.view.width-20, 60);
        
    }else{
    
        return CGSizeMake(self.view.width-20, self.view.width/4);
    }
}

- (void)share:(NSIndexPath *)indexPath
{
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
#ifdef DEBUG
    NSLog(@"%s", __FUNCTION__);
#endif
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
